<template>
  <div class="toppart">
        <div class="topbar">
          <div class="container">
            <div class="top1">
              <nuxt-link to="/" class="active"> 首页</nuxt-link>
              <a href="http://www.qikan.com.cn/" >龙源期刊网</a>
            <div class="fr">

<!-- 注册 -->
<div class="zc_dl hand" v-show="!isLogin" @click="gozhuce">注册</div>

<!-- 登录 -->
<div class="zc_dl hand" v-show="!isLogin"  @click="godenglu">登录</div>

<!-- 已登录 -->

               <div class="avatar hand" @click="openset" v-show="isLogin">
                 <img :src="poster" >
                 <div class="info" v-show="isSet">
                   <li class="pp1 hand"  @click="toHome">我的主页</li>
                   <li  class="pp2 hand" @click="accountSetting()">账号设置</li>
                   <li  class="pp3 hand"  @click="loginOut()">安全退出</li>
                 </div>
               </div>
            </div>

            </div>
          </div>
        </div>

        <div class="bg-logopart1">
         <div class="container">
          <div class="top2">
            <span class="top2-1"><nuxt-link to="/" ><img src="../assets/images/top2-logo.png"></nuxt-link></span>
            <span class="top2-2">

              <input type="text" name="account123" style="display:none;" auto-complete="off"/>
              <input type="password" name="password123" style="display:none;" auto-complete="off"/>
            <el-input placeholder="请输入内容" v-model="input5" class="input-with-select" @keyup.enter.native="goSearch" v-show="isShow == true">
              <el-select v-model="select" @change="selectTrigger(select)"  slot="prepend" placeholder="智能检索" style="width:130px;padding-left:20px; " class="searchicon">
                <el-option label="智能检索" value="1"></el-option>
                <el-option label="高级检索" value="2"></el-option>
              </el-select>
<el-button slot="append" style="background-color:#0084ff; color:#f0f3f5;border-radius:0; border-top-right-radius: 3px; border-bottom-right-radius: 3px;" @click="goSearch">搜索</el-button>            </el-input>

          </span>
           <span class="top2-3"><img src="../assets/images/top2-zhengban.png"></span>
           <span class="top2-4"><img src="../assets/images/top2-zhuanye.png"></span>

          </div>
        </div>
      </div>

<!-- 提示信息 -->
<div class="tipinfo" v-show="isTip">{{tipword}}</div>
    <div class="mask" v-show="isSetPassword">
      <div class="forgetbox" >
        <div class="close hand" @click="closeWindow(100)"></div>
        <div class="fftitle">设置密码</div>
        <div class="ffbox">
          <input type="password" class="ffinputtext" v-model="newpass" maxlength="10" placeholder="设置密码（8位以上数字和字母）">
        </div>
        <div class="ffbox">
          <input type="password" class="ffinputtext" maxlength="10" v-model="newpassagain" placeholder="再次输入密码">
        </div>
        <div class="ffnextbtn hand" @click="goSetPass1">提交</div>
      </div>
    </div>

<!-- 注册部分 -->
<div class="mask" v-show="zhuce">
  <div class="box">
     <div class="wenku hand" @click="closeWindow"></div>
    <div class="wenkudec">5000+媒体的知识发现平台</div>

    <div class="inputbox">
      <input type="text" class="inputtext" v-model="phone_zc" placeholder="请输入手机号">
    </div>
    <div class="inputbox">
        <input type="text" class="inputtext" v-model="yzcode" maxlength="6" placeholder="请输入验证码">
          <div class="yanzheng hand" @click="sendCode(1)" v-show="sendAuthCode" >发送验证码</div>
          <div class="yanzheng hand" v-show="!sendAuthCode" > <span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

    </div>


    <div class="gap70"></div>
    <div class="wkbtn hand" @click="login(1)">注册</div>
    <div class="wktip">注册即代表同意<span @click="goWKXY" class="hand c225599">《文库协议》</span><span @click="goYSBHZY" class="hand c225599">《隐私保护指引》</span></div>


    <div class="wkbottom">已有账号？<a @click="linkdenglu" class="hand">登录</a></div>
  </div>
</div>

<!-- 密码登录部分 -->
<div class="mask" v-show="denglu">
  <div class="box">
    <div class="wenku hand" @click="closeWindow"></div>
    <div class="wenkudec">5000+媒体的知识发现平台</div>
    <div class="inputbox">
      <input type="text" class="inputtext" v-model="phone_dl" placeholder="请输入手机号或邮箱">
    </div>
    <div class="inputbox">
        <input type="password" class="inputtext"maxlength="10" v-model="password_dl" placeholder="请输入密码">
    </div>

    <div class="gap70"><span @click="yzlogin" class="hand">手机验证码登录</span>  <div class="fr hand" @click="forgetpass">忘记密码</div></div>
    <div class="wkbtn hand" @click="login(5)">登录</div>
    <div class="wktip1">社交账号登录
      <div class="apa">
        <span style="cursor:pointer" @click="getQrCode(1)"><img src="../assets/images/icon-weixin.png" height="27"  width="35" alt=""/></span>
        <span style="cursor:pointer" @click="getQrCode(2)"><img src="../assets/images/icon-qq.png" height="27" width="27" @click="getQrCode(2)" alt=""/></span>
        <span style="cursor:pointer" @click="getQrCode(3)"><img src="../assets/images/icon-weibo.png" height="27"  width="27" alt=""/></span>
      </div>
    </div>
    <div class="wkbottom">没有账号？<a @click="linkzhuce" class="hand" >注册</a></div>
  </div>
</div>

<!-- 验证码登录部分 -->
<div class="mask" v-show="yzdenglu">
  <div class="box">
    <div class="wenku hand" @click="closeWindow"></div>
    <div class="wenkudec">5000+媒体的知识发现平台</div>
    <div class="inputbox">
      <input type="text" class="inputtext" v-model="phone_dllogin" placeholder="请输入手机号">
    </div>
    <div class="inputbox">
        <input type="text" class="inputtext" maxlength="6" v-model="yzcodelogin" placeholder="请输入验证码">
          <div v-show="sendAuthCodeLogin" @click="sendCode(2)" class="yanzheng hand">发送验证码</div>
      <div v-show="!sendAuthCodeLogin" class="yanzheng hand"><span class="auth_text_blue">{{auth_time}} </span> 秒后重新发送</div>

    </div>

    <div class="gap70"><span @click="passlogin" class="hand">密码登录（手机号或邮箱）</span> </div>
    <div class="wkbtn hand" @click="login(2)">登录</div>
    <div class="wktip1">社交账号登录
      <div class="apa">
        <span style="cursor:pointer" @click="getQrCode(1)"><img src="../assets/images/icon-weixin.png" height="27"  width="35" alt=""/></span>
        <span style="cursor:pointer" @click="getQrCode(2)"><img src="../assets/images/icon-qq.png" height="27" width="27" @click="getQrCode(2)" alt=""/></span>
        <span style="cursor:pointer" @click="getQrCode(3)"><img src="../assets/images/icon-weibo.png" height="27"  width="27" alt=""/></span>
      </div>
    </div>
    <div class="wkbottom">没有账号？<a @click="linkzhuce" class="hand">注册</a></div>
  </div>
</div>
<!-- 忘记密码 -->
<div class="mask" v-show="forget">
<!-- 忘记密码 第一步 -->
    <div class="forgetbox" v-show="step1">
      <div class="close hand" @click="closeWindow"></div>
      <div class="fftitle">找回密码</div>
      <div class="ffdec">验证码将会发送至你的注册邮箱或手机</div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="ffaccount" placeholder="手机号或邮箱">
      </div>
      <div class="ffnextbtn hand" @click="goStep2">下一步</div>
    </div>
<!-- 忘记密码 第二步 -->
    <div class="forgetbox" v-show="step2">
      <div class="close hand" @click="closeWindow"></div>
      <div class="fftitle">找回密码</div>
      <div class="ffdec">验证码将会发送至你的注册邮箱或手机</div>
       <div class="ffbox">
         <div class="ffinputtext">{{ffaccount}}</div>
         <div class="ffyanzheng hand" @click='goStep1'>修改</div>
       </div>
      <div class="ffbox">
        <input type="text" class="ffinputtext" v-model="step2code" maxlength="6" placeholder="请输入6位验证码">
         <div class="ffyanzheng hand" v-show="sendforgetCode" @click="sendCode(3)">发送验证码</div>
        <div class="ffyanzheng hand" v-show="!sendforgetCode">{{sendforgettime}}秒后过期</div>

      </div>
      <div class="ffnextbtn hand" @click="goStep3">下一步</div>
    </div>


 <!-- 忘记密码 第三步 -->
    <div class="forgetbox" v-show="step3">
      <div class="close hand" @click="closeWindow"></div>
      <div class="fftitle">设置新密码</div>
      <div class="ffdec">新密码应不少于8位，且不可与之前的设置过得密码重复</div>
       <div class="ffbox">
          <input type="password" class="ffinputtext" maxlength="10" v-model="newpass" placeholder="新密码">
       </div>
      <div class="ffbox">
        <input type="password" class="ffinputtext" maxlength="10" v-model="newpassagain" placeholder="再次输入新密码">
      </div>
      <div class="ffnextbtn hand" @click="goStep4">下一步</div>
    </div>
<!-- 忘记密码 第四步 -->
    <div class="forgetbox" v-show="step4">
          <div class="ffok">设置成功</div>
<div class="ffnextbtn hand" @click="godenglu">完成</div>
    </div>

 </div>


  </div>
</template>
<script>
  import axios from 'axios'
  import qs from 'qs'
  export default {
    data: () => ({
      isShow:true,
      nohigh:true,
    isSet: false,
    input5:'',
    select:'智能检索',
    isLogin:false,
    zhuce:false,
    denglu:false,
    yzdenglu:false,
    phone_dl:'',
    phone_dllogin:'',
    phone_zc:'',
    yzcode:'',
    password_dl:'',
    yzcodelogin:'',
    // 提示
    isTip:false,
    tipword:'',

    //忘记密码
    forget:false,
    step1:false,
    step2:false,
    step3:false,
    step4:false,
    step2code:'',
    ffaccount:'',
    newpass:'',
    newpassagain:'',
      sendAuthCode:true,/*布尔值，通过v-show控制显示‘获取按钮’还是‘倒计时’ */
      auth_time: 0, /*倒计时 计数器*/
      sendAuthCodeLogin:true,
      sendforgetCode:true,
      sendforgettime:0,
      poster:'../assets/images/r-1.png',
      isSetPassword:false,
      newpassagain:'',
      newpass:'',
      user:''


  }),created(){
      this.setSelect();
      var path = this.$route.path;
      if(path == '/advancesearch' | path == '/advancesearch/'){
        this.isShow = false;
      }
    },mounted(){
      console.log("infoddd")
      this.user=JSON.parse(localStorage.getItem("user"));
      // this.user=localStorage.getItem(JSON.parse("user"));
      if(this.user!=null && this.user!="" && this.user!=undefined){
        this.poster=this.user.poster;
        console.log("uuaa  "+this.user.mobile)
        this.isLogin=true;
      }
      //this.getSessionUser();
    },
    methods:{
      goWKXY(){
        this.$router.push({path:'/info/2'});
      },
      goYSBHZY(){
        this.$router.push({path:'/info/8'});
      },getSessionUser(){

        let key=localStorage.getItem("user_unique_code");

        if(key!=null && key!="" && key!=undefined){
          console.log("key存在 "+key)
          axios.post('https://wenku.qikan.com:11000/admin/lib/getTokenByUserId.html',qs.stringify({'key':key})
          )
            .then((response)=>{
              console.log("resultuser "+response.data);
              let result= response.data;
              console.log("用户信息  "+result)
              if(result.code==1){
                console.log("用户存在")
                console.log(result.data.trim())
                this.user=JSON.parse(result.data.trim());
                console.info("usermsg "+this.user)
                if(this.user!=null && this.user!="" && this.user!=undefined){
                  this.poster=this.user.poster;
                  console.log("uuaa  "+this.user.mobile)
                  this.isLogin=true;
                }
              }else{//用户已经过期了
                axios.post('https://wenku.qikan.com:11000/admin/lib/getUserByUniqueCode.html',qs.stringify({'unique_code':key})
                )
                  .then((response)=>{
                    console.log(response.data);
                    let result= response.data;
                    if(result.code==1){
                      //获取用户信息成功
                      localStorage.removeItem("user_unique_code");
                      localStorage.setItem("user_unique_code",result.data.unique_code);
                      console.log("用户信息lalala "+result.data);
                      this.user =result.data;
                      let v=JSON.stringify(this.user);
                      console.log(this.user)
                      axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
                        .then(function(res){

                          console.log(res.data.data);
                        })
                      axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
                        .then(function(res){
                          console.log(res.data.data);
                        })
                      console.log("用户不存在！")
                      if(this.user!=null && this.user!="" && this.user!=undefined){
                        this.poster=this.user.poster;
                        console.log("uuaa  "+this.user.mobile)
                        this.isLogin=true;
                        console.log("topbarload end")
                      }
                    }else{
                      this.tipshow("用户已过期，请重新登陆！")
                      this.$router.push({path: '/'});
                    }
                  })
                  .catch((error)=>{
                    console.log(error)
                  })

              }
            })
            .catch((error)=>{
              console.log(error)
            })
        }else{
          console.log("key不存在 ")
          return null;
        }
      },getTopBarUser(){
        this.user=localStorage.getItem(JSON.parse("user"));
        if(this.user=null || this.user=="" || this.user==undefined){
          this.$router.push({path: '/'});
        }else{//从后台获取用户

          axios.post('https://wenku.qikan.com:11000/admin/lib/getUserByUniqueCode.html',qs.stringify({'unique_code':key})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1){

              }else{
                this.tipshow("用户已过期，请重新登陆！")
                this.$router.push({path: '/'});
              }
            })
            .catch((error)=>{
              console.log(error)
            })
        }
      },


      setSelect(){
        var path = this.$route.path;
        if(path=='/advancesearch'){
          this.select = '高级检索';
          this.nohigh =  false;
        }
      }, goSetPass1(){
        // let regExp=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,21}$/;
        // let regu = "^[0-9a-zA-Z]{8,10}$";
        // let regExp = new RegExp(regu);
        let regExp = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);
        console.log("info")
        if(this.newpass==null || this.newpass=="" || this.newpass==undefined){
          console.log("info1")

          this.tipshow("新密码不能为空！");
          return false;
        }else if(this.newpassagain==null || this.newpassagain=="" || this.newpassagain==undefined){
          console.log("info2")

          this.tipshow("请再次输入密码！");
          return false;
        }else if(this.newpass!=this.newpassagain){
          console.log("info3")

          this.tipshow("两次密码输入不一致！");
          return false;
        }else if(!regExp.test(this.newpass) ||!regExp.test(this.newpassagain)|| this.newpass.length<8 || this.newpass.length>10
          || this.newpassagain<8 || this.newpassagain>10){
          console.log("info4")

          this.tipshow("密码格式不正确！");
          return false;
        }else{
          console.log("info5")
          console.log(this.yzcode+"  "+this.phone_zc);
          axios.post('https://wenku.qikan.com:11000/admin/lib/mobileRegister.html',qs.stringify({'mobile':this.phone_zc,'validcode':this.yzcode})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1)
              {
                // this.tipshow("注册成功，请设置密码！");
                this.cancelRegister();
                this.yzcode='';
                // this.isSetPassword=true;
                // // this.goSetPass();
                // // this.cancelRegister();
                axios.post('https://wenku.qikan.com:11000/admin/lib/setPwd.html',qs.stringify({'mobile':this.phone_zc,'pwd':this.newpass,'pwdAgain':this.newpassagain})
                )
                  .then((response)=>{
                    console.log(response.data);
                    let result= response.data;
                    if(result.code==1){
                      this.isSetPassword=false;
                      this.phone_zc=''
                      // localStorage.removeItem("user");
                      // localStorage.setItem("user", JSON.stringify(result.data));
                      localStorage.removeItem("user");
                      localStorage.setItem("user",JSON.stringify(result.data));
                      this.user =JSON.parse(localStorage.getItem("user"))
                      // let v=JSON.stringify(this.user);
                      // console.log(this.user)
                      // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
                      //   .then(function(res){
                      //
                      //     console.log(res.data.data);
                      //   })
                      // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
                      //   .then(function(res){
                      //     console.log(res.data.data);
                      //   })
                      // this.tipshow("设置密码成功，请登录！")
                      this.newpass='';
                      this.newpassagain='';
                      this.phone_zc='';

                      window.location.href="/person/setup";
                      this.cancelRegister()
                      // localStorage.removeItem("user");
                      // localStorage.setItem("user", JSON.stringify(result.data));
                    }else{
                      this.tipshow("设置密码失败！")
                    }
                  })
                  .catch((error)=>{
                    console.log(error)
                  })

              }else{
                this.tipshow(result.message());
              }


            })
            .catch((error)=>{
              console.log(error);
              this.tipshow(error.message);
            })


          console.log('设置密码成功')
        }


      },
      selectTrigger(id){
        if(id==1){
          this.$router.push({path:'/search'});
        }else{
          this.select = '高级检索';
          this.$router.push({path:'/advancesearch'});
          this.nohigh = false;
        }
      },
      goSearch(){
        this.$router.push({path:'/search?key='+this.input5});
      },
      getQrCode(logintype){
        if(logintype==2){
          window.location.href='http://39.98.63.19:12000/admin/lib/qqauthorizationredirect.html?loginType=2'
          // axios.get('https://wenku.qikan.com:11000/admin/lib/qqauthorizationredirect.html',qs.stringify({'loginType':logintype})
          // )
          //   .then((response)=>{
          //     console.log(response.data);
          //     // let result= response.data;
          //     // //this.$router.push({path: result});
          //     // window.location.href=result;
          //   })
          //   .catch((error)=>{
          //     console.log(error)
          //   })
        }else{
        axios.post('https://wenku.qikan.com:11000/admin/lib/authorizationredirect.html',qs.stringify({'loginType':logintype})
        )
          .then((response)=>{
            console.log(response.data);
            let result= response.data;
            //this.$router.push({path: result});
            window.location.href=result;
          })
          .catch((error)=>{
            console.log(error)
          })
        }
      },
      sendCode(type) {
        var mobilereg = /^1[345789]\d{9}$/;
        var phone='';
        if(type==1){//注册
          if (this.phone_zc == null || this.phone_zc == "" || this.phone_zc == 'undefined') {
            this.tipshow("手机号不能为空!");
            return false;
          } else if (!mobilereg.test(this.phone_zc)) {
            this.tipshow("手机格式不正确");
            return false;
          }
          phone=this.phone_zc;
        }else if(type==2){//登录
          if (this.phone_dllogin == null || this.phone_dllogin == "" || this.phone_dllogin == 'undefined') {
            this.tipshow("手机号不能为空!");
            return false;
          } else if (!mobilereg.test(this.phone_dllogin)) {
            this.tipshow("手机格式不正确");
            return false;
          }
          phone=this.phone_dllogin;
        }else if(type==3){
          let mobilereg = /^1[345789]\d{9}$/;
          let mailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;

          if(this.ffaccount!=null){
            if(mobilereg.test(this.ffaccount)){//发送手机短信
              axios.post('https://wenku.qikan.com:11000/admin/lib/sendmsg.html',qs.stringify({'mobile':this.ffaccount})
              )
                .then((response)=>{
                  console.log(response.data);
                  let result= response.data;
                  if(result.code==1)
                  {
                    this.sendforgetCode=false;
                    // this.tipshow("验证码发送成功");
                    this.sendforgettime = 60;
                    var auth_timetimer =  setInterval(()=>{
                      this.sendforgettime--;
                      if(this.sendforgettime<=0){

                          this.sendforgetCode = true;

                        clearInterval(auth_timetimer);
                      }
                    }, 1000);
                    this.start1 = true;
                  }
                })
                .catch((error)=>{
                  console.log(error)
                })
            }else{
              if( mailReg.test(this.ffaccount)){//邮箱发送
                axios.post('https://wenku.qikan.com:11000/admin/lib/sendMailCode.html',qs.stringify({'email':this.ffaccount})
                )
                  .then((response)=>{
                    console.log(response.data);
                    let result= response.data;
                    if(result.code==1)
                    {
                      this.sendforgetCode=false;
                      // this.tipshow("验证码发送成功");
                      this.sendforgettime = 60;
                      var auth_timetimer =  setInterval(()=>{
                        this.sendforgettime--;
                        if(this.sendforgettime<=0){

                          this.sendforgetCode = true;

                          clearInterval(auth_timetimer);
                        }
                      }, 1000);
                      this.start1 = true;
                    }
                  })
                  .catch((error)=>{
                    console.log(error)
                  })

              }
            }

            this.step1=false;
            this.step2=true;
          }else{
            this.tipshow("手机号或邮箱格式不正确！")
          }

        }
          axios.post('https://wenku.qikan.com:11000/admin/lib/sendmsg.html',qs.stringify({'mobile':phone})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1)
              {
                if(type==1){
                  this.sendAuthCode = false;

                }else if(type==2){
                  this.sendAuthCodeLogin=false;
                }
                this.auth_time = 60;
                var auth_timetimer =  setInterval(()=>{
                  this.auth_time--;
                  if(this.auth_time<=0){
                    if(type==1){
                      this.sendAuthCode = true;
                    }else if(type==2){
                      this.sendAuthCodeLogin=true;
                    }
                    clearInterval(auth_timetimer);
                  }
                }, 1000);
                this.start1 = true;
              }else{
                this.tipshow("验证码发送失败！");

              }
            })
            .catch((error)=>{
              console.log(error)
            })

      },toHome(){
        this.$router.push({path: '/person/collect'});
      },
      loginOut(){
        localStorage.removeItem("user")
        // localStorage.removeItem("user");
        window.location.href="/";
        // var user=JSON.parse(localStorage.getItem("user"));
        // if(user!=null && user!="" && user!=undefined){
        //   console.log("uuaa  "+user.mobile)
        //   this.isLogin=true;
        // }
        //this.$router.push({path: '/'});

      },
      accountSetting(){
        this.$router.push({path: '/person/setup'});
      },
      toHome(){
        this.$router.push({path: '/person/collect'});
      },
      login(type){

        var mobilereg = /^1[345789]\d{9}$/;
        let mailReg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z\-]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;

        var phone='';
        if(type==1){//注册
          if (this.phone_zc == null || this.phone_zc == "" || this.phone_zc == undefined) {
            this.tipshow("手机号不能为空!");
            return false;
          } else if (!mobilereg.test(this.phone_zc)) {
            this.tipshow("手机格式不正确");
            return false;
          }else if(this.yzcode==null || this.yzcode =="" || this.yzcode == undefined || this.yzcode.length!=6){
            this.tipshow("验证码为空或长度不正确！");
            return false;
          }
          phone=this.phone_zc;
          axios.post('https://wenku.qikan.com:11000/admin/lib/checkUserIsNotNull.html',qs.stringify({'mobile':this.phone_zc})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1){
                this.tipshow("用户已存在，请登录！")
                return false;
              }else{
                this.cancelRegister();
                this.isSetPassword=true;

              }
            })
            .catch((error)=>{
              console.log(error)
            })


        }else if(type==2){//登录
          if (this.phone_dllogin == null || this.phone_dllogin == "" || this.phone_dllogin == 'undefined') {
            this.tipshow("手机号不能为空!");
            return false;
          } else if (!mobilereg.test(this.phone_dllogin)) {
            this.tipshow("手机格式不正确");
            return false;
          }else if(this.yzcodelogin==null || this.yzcodelogin =="" || this.yzcodelogin == undefined || this.yzcodelogin.length!=6){
            this.tipshow("验证码为空或长度不正确！");
            return false;
          }
          phone=this.phone_dllogin;
          axios.post('https://wenku.qikan.com:11000/admin/lib/validcodeLogin.html',qs.stringify({'mobile':phone,'validcode':this.yzcodelogin})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1)
              {
                this.tipshow("登录成功！");
                // localStorage.removeItem("user");
                // localStorage.setItem("user_unique_code", JSON.stringify(result.data.unique_code));
                localStorage.removeItem("user");
                localStorage.setItem("user",JSON.stringify(result.data));
                this.user =JSON.parse(localStorage.getItem("user"))
                // let v=JSON.stringify(this.user);
                // console.log(this.user)
                // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
                //   .then(function(res){
                //
                //     console.log("移除用户成功"+res.data.data);
                //   })
                // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
                //   .then(function(res){
                //     console.log("设置用户成功"+res.data.data);
                //   })
                // var user=JSON.parse(localStorage.getItem("user"));
                this.poster=this.user.poster;
                this.isLogin=true;
                this.cancelLogin();
                // this.$router.push({path: '/'});
                let a=localStorage.getItem("failuretime");
                if(a!=null && a!="" && a!=undefined){
                  console.log(a)

                  var timestamp = Date.parse(new Date())
                  console.log(timestamp)
                  if(timestamp<=a){
                    let k=localStorage.getItem("key");
                    console.log(k)
                    localStorage.removeItem("key");
                    localStorage.removeItem("failuretime")
                    let jumpurl=localStorage.getItem("jumpurl");
                    console.log("jumpurl   "+jumpurl);
                    localStorage.removeItem("jumpurl")

                    if(jumpurl=='/article'){
                      window.location.href="/article?collkey="+k
                    }else if(jumpurl=='/advancesearch'){
                      window.location.href="/advancesearch"
                    }else if(jumpurl=='/search'){
                      window.location.href="/search?key="+k
                    }else if(jumpurl=='/list/id'){
                      window.location.href="/list/id?id="+k
                    }


                  }else{
                    this.$router.push({path: '/'});
                  }
                }else{
                  this.$router.push({path: '/'});
                }


              }else{
                this.tipshow(result.message);
              }


            })
            .catch((error)=>{
              console.log(error);
              this.tipshow(error.message);
            })

        }else if(type==5){//用户名密码登录
          // let regu = "^[0-9a-zA-Z]{8,10}$";
          // let regExp = new RegExp(regu);
          let regExp = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);

          if (this.phone_dl == null || this.phone_dl == "" || this.phone_dl == undefined) {
            this.tipshow("账号不能为空!");
            return false;
          } else if (!mailReg.test(this.phone_dl) && !mobilereg.test(this.phone_dl)) {
            this.tipshow("账号格式不正确");
            return false;
          }else if(!regExp.test(this.password_dl) || this.password_dl.length<8 || this.password_dl>10){
            console.log("info4")

            this.tipshow("密码格式不正确！");
            return false;
          }
          phone=this.phone_dl;
          axios.post('https://wenku.qikan.com:11000/admin/lib/login.html',qs.stringify({'username':phone,'logintype':2,'pwd':this.password_dl})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1)
              {
                this.tipshow("登录成功！");
                // localStorage.removeItem("user");
                // localStorage.setItem("user", JSON.stringify(result.data));
                // var user=JSON.parse(localStorage.getItem("user"));
                // localStorage.removeItem("user_unique_code");
                // localStorage.setItem("user_unique_code",result.data.unique_code);
                // var user=result.data.parseJSON();
                // this.poster=user.poster;
                localStorage.removeItem("user");
                localStorage.setItem("user",JSON.stringify(result.data));
                 this.user =JSON.parse(localStorage.getItem("user"))
                // let v=JSON.stringify(this.user);
                // console.log("uservalue "+v)
                // axios.post('https://wenku.qikan.com:11000/admin/lib/removeTokenByUserId.html',qs.stringify({'key':result.data.unique_code}))
                //   .then(function(res){
                //     console.log("removeTokenByUserId ")
                //     console.log(res.data.data);
                //   })
                // axios.post('https://wenku.qikan.com:11000/admin/lib/setTokenByUserId.html',qs.stringify({'key':result.data.unique_code,'value':v}))
                //   .then(function(res){
                //     console.log("setTokenByUserId ")
                //
                //     console.log(res.data.data);
                //   })
                // var user=JSON.parse(localStorage.getItem("user"));
                this.poster=this.user.poster;
                this.isLogin=true;
                this.cancelLogin();
                this.denglu=false;
                // this.$router.push({path: '/'});
                let a=localStorage.getItem("failuretime");
                if(a!=null && a!="" && a!=undefined){
                  console.log(a)

                  var timestamp = Date.parse(new Date())
                  console.log(timestamp)
                  if(timestamp<=a){
                    let k=localStorage.getItem("key");
                    console.log(k)
                    localStorage.removeItem("key");
                    localStorage.removeItem("failuretime")
                    let jumpurl=localStorage.getItem("jumpurl");
                    localStorage.removeItem("jumpurl")

                    if(jumpurl=='/article'){
                      window.location.href="/article?collkey="+k
                    }else if(jumpurl=='/advancesearch'){
                      window.location.href="/advancesearch"
                    }else if(jumpurl=='/search'){
                      window.location.href="/search?key="+k
                    }else if(jumpurl=='/list/id'){
                      window.location.href="/list/id?id="+k
                    }
                  }else{
                    this.$router.push({path: '/'});
                  }
                }else{
                  this.$router.push({path: '/'});
                }

              }else{
                this.tipshow(result.message);
              }
            })
            .catch((error)=>{
              console.log(error);
              this.tipshow(error.message);
            })

        }

      },
      openset(){
        this.isSet=!this.isSet;
      },jumpPage(){

      },
      godenglu(){
          this.denglu=true;
          this.step4=false;
          this.forget=false;
      },
      cancelLogin(){
        this.yzdenglu=false;
      },
      gozhuce(){
        this.zhuce=true;
      },
      cancelRegister(){
        var t=setTimeout(1000);
        this.zhuce=false;
      },
      linkdenglu(){
        this.denglu=true;
        this.zhuce=false;
      },
      linkzhuce(){
        this.yzdenglu=false;
        this.denglu=false;
        this.zhuce=true;
      },
      yzlogin(){
       this.yzdenglu=true;
       this.denglu=false;
      },
      passlogin(){
       this.yzdenglu=false;
       this.denglu=true;
      },


      closeWindow(type){
        this.yzdenglu=false;
        this.denglu=false;
        this.zhuce=false;
        this.forget=false;
        this.step1=false;
        this.step2=false;
        this.step3=false;
        this.step4=false;
        if(type==100){
          this.isSetPassword=false;
          this.$router.push({path: '/'});
        }
      },
//忘记密码
      forgetpass(){
        this.forget=true;
        this.denglu=false;
        this.step1=true;
      },
      goStep1(){
        this.step2=false;
        this.step1=true;
      },
      goStep2(){
        let mobilereg = /^1[34578]\d{9}$/;
        let mailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;

        if(this.ffaccount!=null && (mobilereg.test(this.ffaccount) || mailReg.test(this.ffaccount))){
          axios.post('https://wenku.qikan.com:11000/admin/lib/checkUserIsExist.html',qs.stringify({'mobile':this.ffaccount})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1)
              {
                this.step1=false;
                this.step2=true;

              }else{
                this.tipshow("用户不存在，请注册");
              }


            })
            .catch((error)=>{
              console.log(error);
              this.tipshow(error.message);
            })
          //判断手机号或者邮箱是否绑定

        }else{
          this.tipshow("手机号或邮箱格式不正确！")
        }

      },
      goStep3(){
        let mobilereg = /^1[345789]\d{9}$/;
        let mailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
        if(this.ffaccount!=null &&  mailReg.test(this.ffaccount)){
          axios.post('https://wenku.qikan.com:11000/admin/lib/checkEmailCode.html',qs.stringify({'email':this.ffaccount,'msg':this.step2code})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1)
              {
                this.step2=false;
                this.step3=true;

              }else{
                this.tipshow(result.message);
              }


            })
            .catch((error)=>{
              console.log(error);
              this.tipshow(error.message);
            })
        }else{
          this.step2=false;
          this.step3=true;
        }


      },
      goStep4(){
        this.goSetPass();

      },goSetPass(){
        // let regExp=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,21}$/;

         //let regu = "^[0-9a-zA-Z]{8,10}$";
        let regExp = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);
        console.log("info")
        if(this.newpass==null || this.newpass=="" || this.newpass==undefined){
          console.log("info1")

          this.tipshow("新密码不能为空！");
          return false;
        }else if(this.newpassagain==null || this.newpassagain=="" || this.newpassagain==undefined){
          console.log("info2")

          this.tipshow("请再次输入密码！");
          return false;
        }else if(this.newpass!=this.newpassagain){
          console.log("info3")

          this.tipshow("两次密码输入不一致！");
          return false;
        }else if(!regExp.test(this.newpass) ||!regExp.test(this.newpassagain)|| this.newpass.length<8 || this.newpass.length>10
          || this.newpassagain<8 || this.newpassagain>10){
          console.log("info4")

          this.tipshow("密码格式不正确！");
          return false;
        }else{
          console.log("info5")

          axios.post('https://wenku.qikan.com:11000/admin/lib/setPwd.html',qs.stringify({'mobile':this.ffaccount,'pwd':this.newpass,'pwdAgain':this.newpassagain})
          )
            .then((response)=>{
              console.log(response.data);
              let result= response.data;
              if(result.code==1){
                this.step3=false;
                this.step4=true;
                console.log('设置密码成功')

              }else{
                this.tipshow(result.message)
              }
            })
            .catch((error)=>{
              console.log(error)
            })

        }


      },


      tipshow(e){
        this.tipword=e;
        this.isTip=true;
        setTimeout(() => {
           this.tipword='';
           this.isTip=false;
       }, 2000);
    },getAuthCode() {
        this.sendAuthCode = false;
        this.auth_time = 6;
        var auth_timetimer = setInterval(() => {
          this.auth_time--;
          if (this.auth_time <= 0) {
            this.sendAuthCode = true;
            clearInterval(auth_timetimer);
          }
        }, 1000);
      }
    }
  }

</script>
<style scoped>
.tipinfo{position: fixed; z-index: 9999; top: 50%; left: 50%; width: 400px;  height: 40px;border-radius: 10px; margin-left: -200px; margin-top: -20px; line-height: 40px;text-align: center;color: #fff; font-size: 14px; background-color: rgba(50,50,50,0.8)}

.topbar{ width: 100%; height: 54px;background-image: linear-gradient(-180deg, #086ED4 0%, #0767C7 50%, #065DB5 100%, rgba(0,0,0,0.50) 100%);
  box-shadow: 0 2px 4px 0 rgba(77,77,77,0.50);}
.bg-logopart1{ width: 100%; height: 86px; background: #fff;}

.top1{ width: 100%; height: 54px; line-height: 54px; }
.avatar{width: 31px; height: 54px; padding-top: 12px; position: relative; display: inline-block;}
.avatar img{ width: 31px; height: 31px; }
.avatar .info{ position: absolute; z-index: 100; width: 173px; height: 140px; padding: 10px 0; top: 48px;  right: 0px; background-color: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,0.06);border-radius: 4px; }
.avatar .info li{ width: 100%; height: 40px; line-height: 40px; text-align: center; cursor: pointer;padding-left: 20px; }
.avatar .info li:hover{ background-color: #f6f6f6;}

.top2{ width: 100%; height: 86px; padding: 18px 0 28px; line-height: 40px; }
.top2-1{ width: 224px; height: 40px;  display: inline-block; margin-right: 32px;  position: relative; float: left;}
.top2-1 img{ width: 190px; height: 54px; position: absolute; left: 0; top: -7px; }
.top2-2{ width: 650px; height: 40px;  display: inline-block; margin-right: 21px;position: relative; float: left;}
.top2-3{ width: 100px; height: 40px;  display: inline-block; margin-right: 10px;position: relative; float: left;}
.top2-4{ width: 100px; height: 40px;  display: inline-block;position: relative; float: left; }
.top2-3 img,.top2-4 img{ width: 100px; height: 40px;  display: block; vertical-align: middle;}


a{color:#f0f3f5; text-decoration: none; font-size: 16px; padding:0 15px;}
.active{ background: #0560B7;box-shadow: inset 0 0 1px 0 rgba(79,79,79,0.50); height: 52px; display: inline-block; color: #f0f3f5; }

.zc_dl{ width: 75px; height: 35px;background: #0D78E7;border: 1px solid #055BB2;box-shadow: inset 0 1px 1px 0 #368EF2;border-radius: 3px; line-height: 33px; text-align: center;font-size: 16px; display: inline-block; color:#fff; margin-left: 30px;}

/* 注册登录部分 */

.mask{ width: 100%; z-index: 99;height: 100%; background: rgba(24,24,24,0.50); position: fixed;z-index: 999; left: 0; top: 0; }
.box{ position: fixed; z-index:1000; width: 500px; height: 575px; animation:skin .5s ;left: calc( 50% - 250px ); top :50% ;margin-top:-288px;text-align:center; background-color: #fff; padding: 0 46px;}
@keyframes skin {
  0% {
    opacity: 0;
  }

  25% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.6;
  }
  75% {
    opacity: 0.9;
  }
  100% {
    opacity: 1;
  }
}
.wenku{font-size: 78px;color: #0084FF; height: 93px; margin-top:32px; clear: both; background: url('../assets/images/wenkulogo.png') center center no-repeat; background-size: 231px 74px; position: relative;}
.wenku:after{content: '';position: absolute;top: -15px; right: -15px; width: 32px; height: 32px; background: url('../assets/images/icon-close.png') center center no-repeat; background-size: 14px 14px; }

.wenkudec{font-size: 24px;color: #0084FF;letter-spacing: 2px;line-height: 33px;clear: both;}
.wkbottom{ height: 67px; width: 100%;background: #F6F6F6;line-height: 67px;font-size: 16px; color: #131313;position: absolute; z-index:1001; left:0; bottom:0;}
.wkbottom a{color:#175199;}
.inputbox{ height: 67px; border-bottom: 1px solid #ebebeb; padding: 24px 0 10px; width: 100%; position: relative; }
.inputbox .inputtext{ width: 100%; line-height: 32px; height: 32px; outline: none; border: none; color: #8590A6; text-align: left; font-size: 16px}
.inputbox .yanzheng{position: absolute;z-index: 1001; top:26px; right:0;color: #175199;}

.wktip{font-size: 16px;color: #8590A6;letter-spacing: 0.7px;text-align: center; margin-top:20px;}
.wktip1{font-size: 16px;color: #8590A6;letter-spacing: 0.7px;text-align: left; margin-top:20px; width: 100%;}
.wktip1 .apa{ text-align: right; float: right; display: inline-block; width: 150px; height: 100%; }
.wktip1 .apa span{display: inline-block;margin-right:10px;}.wkbtn{background: #0084FF;border-radius: 3px; width: 100%; height: 42px; line-height: 42px; color:#fff;font-size: 16px;}
.gap70{ width: 100%; height: 70px; clear: both;padding-top:20px;text-align: left; font-size: 16px;color: #175199;}

/* 忘记密码 */
.forgetbox{ width: 380px; height: auto; overflow: hidden; position: fixed; z-index:1000; left: calc( 50% - 190px ); top: calc( 50% - 200px ); background-color: #fff; padding: 30px 40px 24px 36px;}
.forgetbox .close{ position: absolute;z-index: 1001; width: 32px; height: 32px; background: url('../assets/images/icon-close.png') center center no-repeat; background-size: 14px 14px; top:10px; right:10px;}

.ffnextbtn{width: 100%; height: 40px; line-height: 40px; background-color: #0084FF;border-radius: 3px;font-size: 14px; color: #fff; text-align: center;margin-top:60px;}
.fftitle{ width: 100%; line-height: 30px; font-size: 16px; color: #1a1a1a; font-weight: 600; }
.ffdec{width: 100%; line-height: 18px; font-size: 12px; color: #8590A6;}
.ffbox{ height: 60px; border-bottom: 1px solid #ebebeb; padding: 24px 0 10px; width: 100%; position: relative; }
.ffbox .ffinputtext{ width: 100%; line-height: 28px; height: 28px; outline: none; border: none; color: #8590A6; text-align: left;font-size: 16px; }
.ffbox .ffyanzheng{position: absolute;z-index: 1001; top:23px; right:0;color: #175199;font-size: 16px;}
.ffok{border: 1px solid #EBEBEB;border-radius: 3px;height: 40px; line-height: 40px; width: 100%;font-size: 16px;color: #1a1a1a; text-align: center;}
.ffok img{ width: 20px; height: 20px; vertical-align: middle; margin-right: 10px; display: inline-block; }
.pp1{ background: url('../assets/images/account1.png') 30px center no-repeat; background-size: 14px 14px;}
.pp2{ background: url('../assets/images/account2.png') 30px center no-repeat; background-size: 17px 16px;}
.pp3{ background: url('../assets/images/account3.png') 30px center no-repeat; background-size: 15px 16px;}
.searchicon{background: url('../assets/images/icon-magnifier.png') 10px center no-repeat; background-size: 18px 18px;}
  .c225599{color:#225599;}
</style>
